package com.lujieni.springbootrocketmq.service;

import com.alibaba.fastjson.JSON;
import com.lujieni.springbootrocketmq.dto.CsmApproveResultMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
@RocketMQMessageListener(
        // 监听死信队列消息的时候必须重新定义1个新的group
        topic = "%DLQ%springboot-rocketmq",
        selectorExpression = "lujieni",
        // 消费者组
        consumerGroup = "springboot-rocketmq-fuck"
        // 消费失败重试次数 次数超过阈值发往死信队列 不包含首次消费
)
@Slf4j
public class CsmDeadLetterConsumer implements RocketMQListener<CsmApproveResultMessage> {

    @Override
    public void onMessage(CsmApproveResultMessage OrderDTO) {
        log.info("CsmDeadLetterConsumer#onMessage:{}", JSON.toJSONString(OrderDTO));
    }

}